package com.example.gameandroid;

import org.andengine.engine.Engine;
import org.andengine.engine.camera.ZoomCamera;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.sprite.ButtonSprite;
import org.andengine.entity.sprite.ButtonSprite.OnClickListener;
import org.andengine.entity.sprite.Sprite;
import org.andengine.opengl.font.Font;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.texture.region.ITiledTextureRegion;

public class GameOverScene extends Scene {

	private Sprite tela;
	private ButtonSprite botao; 
	
	public GameOverScene(final Engine engine, final ITiledTextureRegion botaoJumpTexture, final ITextureRegion gameOverTelaTexture, 
			final float width, final float height, final ITextureRegion mapaTexture, final Font font, final ZoomCamera camera, final GameBD bd,
			final ITextureRegion rockTexture, final ITiledTextureRegion playerTexture, final ITiledTextureRegion botaoRestartTexture) {
		
		tela = new Sprite(0, 0, gameOverTelaTexture, engine.getVertexBufferObjectManager());
		attachChild(tela);
		engine.getCamera().getHUD().detachSelf(); 
		engine.getCamera().setHUD(null);
		engine.getCamera().setChaseEntity(null);
		engine.getCamera().setCenter(width/2, height/2);
		
		OnClickListener c = new OnClickListener() {
			@Override
			public void onClick(ButtonSprite pButtonSprite, float pTouchAreaLocalX, float pTouchAreaLocalY) {
				setChildScene(new GameScene(height, width, engine, mapaTexture, botaoJumpTexture, playerTexture, camera, font, rockTexture, 
						gameOverTelaTexture, botaoRestartTexture, bd));
			}
		};
		
		botao = new ButtonSprite(0, 0, botaoRestartTexture, engine.getVertexBufferObjectManager(),c);
		botao.setPosition((width/2) - (botao.getWidth() /2), height - botao.getHeight() - 50);
		attachChild(botao);
		registerTouchArea(botao);
	}
}
